<?php

/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// | xml maintenannce
// +---------------------------------------------------------------------------+
// $Id: pro.inc

define ('THIS_SCRIPT', 'assist/pro.php');
//define ('THIS_SCRIPT', 'assist/test.php');

include_once( $_CONF['path_system'] . 'lib-admin.php' );

//
if( function_exists( "LIB_OutLog" )) {
}else{
	include_once ($_CONF['path'] . 'plugins/assist/lib/lib_outlog.php');
}
include_once ($_CONF['path'] . 'plugins/assist/lib/lib_getfilelist.php');
//
include_once ($_CONF['path'] . 'plugins/assist/proversion/pro_assist_functions.inc');





//log 出力モード設定　0:作成しない,1:ファイルに出力
$logmode =1;
$logfile = $_CONF['path_log'] . 'assist_xmlimport.log';

// +---------------------------------------------------------------------------+
// | 機能  menu表示                                                            |
// | 書式 fncMenu()                                                            |
// +---------------------------------------------------------------------------+
// | 戻値 menu                                                                 |
// +---------------------------------------------------------------------------+
function fncMenu(
    $pi_name
)
{

    global $_CONF;
    global $_TABLES;
    global $LANG_ADMIN;
    global $LANG09;
    global $_PLUGINS;

    global $LANG_MAPS_1;

    $lang_box_admin="LANG_".strtoupper($pi_name)."_ADMIN";
    global $$lang_box_admin;
    $lang_box_admin=$$lang_box_admin;

    $lang_box="LANG_".strtoupper($pi_name);
    global $$lang_box;
    $lang_box=$$lang_box;

    $retval = '';

    //MENU1:管理画面

    $url1=$_CONF['site_admin_url'] . '/plugins/'.THIS_SCRIPT.'?mode=init';

    $url10=$_CONF['site_admin_url'] . '/plugins/'.THIS_SCRIPT.'?mode=list';
    $url11=$_CONF['site_admin_url'] . '/plugins/'.THIS_SCRIPT.'?mode=new';
    $url12=$_CONF['site_admin_url'] . '/plugins/'.THIS_SCRIPT.'?mode=exportform';
    $url13=$_CONF['site_admin_url'] . '/plugins/'.THIS_SCRIPT.'?mode=importform';


    //
    $menu_arr[]=array('url' => $url1,'text' => $lang_box_admin['init']);

    $menu_arr[]=array('url' => $url10,'text' => $LANG_ASSIST_ADMIN['xml_def'].$lang_box_admin['list']);
    $menu_arr[]=array('url' => $url11,'text' => $LANG_ASSIST_ADMIN['xml_def'].$lang_box_admin['new']);
    $menu_arr[]=array('url' => $url12,'text' => $lang_box_admin['export']);
    $menu_arr[]=array('url' => $url13,'text' => $lang_box_admin['import']);
    //
    $menu_arr[]=array('url' => $_CONF['site_admin_url'],'text' => $LANG_ADMIN['admin_home']);

    if (in_array("maps", $_PLUGINS)){
        $url20=$_CONF['site_admin_url'] . '/plugins/'.THIS_SCRIPT.'?mode=markerclear';
        $url21=$_CONF['site_admin_url'] . '/plugins/maps/markers.php';
        $menu_arr[]=array('url' => $url20,'text' => "<{XHTML}br><{XHTML}br>".$lang_box_admin['markerclear']);
        $menu_arr[]=array('url' => $url21,'text' => $lang_box_admin['mapsmarker']);
    }

    $function="plugin_geticon_".$pi_name;
    $icon=$function();

    $retval .= ADMIN_createMenu(
        $menu_arr
        ,$lang_box_admin['instructions']
        ,$icon
    );

    return $retval;
}


// +---------------------------------------------------------------------------+
// | 機能  一覧表示
// | 書式 fncList($pi_name)
// +---------------------------------------------------------------------------+
// | 引数 $pi_name:plugin name 'databox' 'userbox' 'formbox'
// +---------------------------------------------------------------------------+
// | 戻値 nomal:一覧
// +---------------------------------------------------------------------------+
function fncList(
    $pi_name
)
{
    global $_CONF;
    global $_TABLES;
    global $LANG_ADMIN;
    global $LANG09;

    $lang_box_admin="LANG_".strtoupper($pi_name)."_ADMIN";
    global $$lang_box_admin;
    $lang_box_admin=$$lang_box_admin;

    $lang_box="LANG_".strtoupper($pi_name);
    global $$lang_box;
    $lang_box=$$lang_box;

    $table=$_TABLES[strtoupper($pi_name).'_def_xml'];
	
	require_once( $_CONF['path_system'] . 'lib-admin.php' );

    $retval = '';


    //ヘッダ：編集～
    $header_arr[]=array('text' => $lang_box_admin['seq'], 'field' => 'seq', 'sort' => true);
    $header_arr[]=array('text' => $LANG_ADMIN['edit'], 'field' => 'editid', 'sort' => false);
    $header_arr[]=array('text' => $lang_box_admin['tag'], 'field' => 'tag', 'sort' => true);

    $header_arr[]=array('text' => $lang_box_admin['value'], 'field' => 'value', 'sort' => true);

    $header_arr[]=array('text' => $lang_box_admin['field'], 'field' => 'field', 'sort' => true);
    $header_arr[]=array('text' => $lang_box_admin['field'], 'field' => 'field2', 'sort' => true);

    //
    $text_arr = array('has_menu' =>  true,
      'has_extras'   => true,
      'form_url' => $_CONF['site_admin_url'] . "/plugins/".THIS_SCRIPT."?mode=list");

    //Query
    $sql = "SELECT ";
    $sql .= " t.seq".LB;
    $sql .= " ,t.tag".LB;
    $sql .= " ,t.value".LB;
    $sql .= " ,t.field".LB;
    $sql .= " ,t.field AS field2".LB;

    $sql .= " FROM ";
    $sql .= " {$table} AS t".LB;
    $sql .= " WHERE ".LB;
    $sql .= " 1=1".LB;
    //

    $query_arr = array(
        'table' =>$table,
        'sql' => $sql,
        'query_fields' => array('t.seq','t.tag','t.value','t.field'
        ),
        'default_filter' => $exclude);
    //デフォルトソート項目:
    $defsort_arr = array('field' => 't.seq', 'direction' => 'ASC');

    //List 取得
    //ADMIN_list($component, $fieldfunction, $header_arr, $text_arr,
    //       $query_arr, $menu_arr, $defsort_arr, $filter = '', $extra = '', $options = '')
    $retval .= ADMIN_list(
        $pi_name
        , "fncGetListField"
        , $header_arr
        , $text_arr
        , $query_arr
        , $defsort_arr
        , $filter
        );

    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));

    return $retval;
}

// +---------------------------------------------------------------------------+
// | 一覧取得 ADMIN_list 経由で使用
// +---------------------------------------------------------------------------+
function fncGetListField($fieldname, $fieldvalue, $A, $icon_arr)
{
    global $_CONF;
    global $LANG_ACCESS;

    $pi_name="assist";


    $retval = '';

    switch($fieldname) {
        //編集アイコン
        case 'editid':
            $retval = "<a href=\"{$_CONF['site_admin_url']}";
            $retval .= "/plugins/".THIS_SCRIPT;
            $retval .= "?mode=edit";
            $retval .= "&amp;seq={$A['seq']}\">";
            $retval .= "{$icon_arr['edit']}</a>";
            break;
        case 'field2':
            $field_ary=fncGetFieldAry($pi_name);
            $retval = $field_ary[$fieldvalue];
            break;

        //各項目
        default:
            $retval = $fieldvalue;
            break;
    }

    return $retval;

}

// +---------------------------------------------------------------------------+
// | 機能  編集画面表示
// | 書式 fncEdit($pi_name,$seq)
// | 書式 fncEdit($pi_name,$seq,$msg,$errmsg)
// +---------------------------------------------------------------------------+
// | 引数 $pi_name:
// | 引数 $seq:
// | 引数 $msg:メッセージ番号
// | 引数 $errmsg:エラーメッセージ
// +---------------------------------------------------------------------------+
// | 戻値 nomal:編集画面                                                       |
// +---------------------------------------------------------------------------+
function fncEdit(
    $pi_name
    ,$seq
    ,$msg = ''
    ,$errmsg=""
)
{
    global $_CONF;
    global $_TABLES;
    global $LANG_ADMIN;
    global $MESSAGE;
    global $LANG_ACCESS;
    global $_USER;

    $lang_box_admin="LANG_".strtoupper($pi_name)."_ADMIN";
    global $$lang_box_admin;
    $lang_box_admin=$$lang_box_admin;

    $lang_box="LANG_".strtoupper($pi_name);
    global $$lang_box;
    $lang_box=$$lang_box;

    $table=$_TABLES[strtoupper($pi_name).'_def_xml'];

    //$lang_box_noyes="LANG_".strtoupper($pi_name)."_NOYES";
    //global $$lang_box_noyes;
    //$lang_box_noyes=$$lang_box_noyes;

    $retval = '';

    $delflg=false;


    if (!empty ($msg)) {
        $retval .= COM_showMessage ($msg,$pi_name);
        $retval .= $errmsg;

        // clean 'em up
        $tag = COM_applyFilter($_POST['tag']);
        $value = COM_applyFilter($_POST['value']);
        $field = COM_applyFilter ($_POST['field']);

        $uuid=$_USER['uid'];

    }else{
        if (empty($seq)) {

            $seq=0;


            $tag = "";
            $value = "";

            $table_id = "";
            $field = "";

            $uuid=0;
            $udatetime="";//"";

        }else{
            $sql = "SELECT ";

            $sql .= " *";

            $sql .= " FROM ";
            $sql .= $table;
            $sql .= " WHERE ";
            $sql .= " seq = $seq";
            $result = DB_query($sql);

            $A = DB_fetchArray($result);

            $tag = COM_stripslashes($A['tag']);
            $value = COM_stripslashes($A['value']);
            $field = COM_stripslashes($A['field']);

            $uuid = COM_stripslashes($A['uuid']);
            $udatetime=COM_stripslashes($A['udatetime']);

            $delflg=true;
        }
    }


    $retval .= COM_startBlock ($lang_box_admin['edit'], '',
                               COM_getBlockTemplate ('_admin_block', 'header'));

    $tmplfld=assist_templatePath('admin','default',$pi_name);

    $templates = new Template($tmplfld);
    $templates->set_file('editor',"xml_editor.thtml");

    //--
    $templates->set_var('about_thispage', $lang_box_admin['about_admin_xml']);
    $templates->set_var('lang_must', $lang_box_admin['must']);
    $templates->set_var('site_url', $_CONF['site_url']);
    $templates->set_var('site_admin_url', $_CONF['site_admin_url']);

    //--
    $token = SEC_createToken();
    $retval .= SEC_getTokenExpiryNotice($token);
    $templates->set_var('gltoken_name', CSRF_TOKEN);
    $templates->set_var('gltoken', $token);
    $templates->set_var ( 'xhtml', XHTML );

    $templates->set_var('script', THIS_SCRIPT);


    //seq
    $templates->set_var('lang_seq', $lang_box_admin['seq']);
    $templates->set_var('seq', $seq);


    //tag value field
    $templates->set_var('lang_tag', $lang_box_admin['tag']);
    $templates->set_var ('tag', $tag);

    $templates->set_var('lang_value', $lang_box_admin['value']);
    $templates->set_var ('value', $value);

    $templates->set_var('lang_field', $lang_box_admin['field']);
    $templates->set_var ('field', $field);

    $list_field=fncgetxmlfieldslist($pi_name,$field );
    $templates->set_var ('list_field', $list_field);


    //保存日時
    $templates->set_var ('lang_udatetime', $lang_box_admin['udatetime']);
    $templates->set_var ('udatetime', $udatetime);
    $templates->set_var ('lang_uuid', $lang_box_admin['uuid']);
    $templates->set_var ('uuid', $uuid);

    // SAVE、CANCEL ボタン
    $templates->set_var('lang_save', $LANG_ADMIN['save']);
    $templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $templates->set_var('lang_preview', $LANG_ADMIN['preview']);

    //delete_option
    if ($delflg){
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete']
               . '" name="mode"%s>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
            $templates->set_var ('delete_option',
                                      sprintf ($delbutton, $jsconfirm));
    }


    //
    $templates->parse('output', 'editor');
    $retval .= $templates->finish($templates->get_var('output'));
    $retval .= COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer'));

    return $retval;
}

// +---------------------------------------------------------------------------+
// | 機能 get xmlfields optionlist html
// | 書式 fncgetxmlfieldslist($pi_name,$field)
// +---------------------------------------------------------------------------+
// | 引数 $pi_name:
// | 引数 $selected:
// +---------------------------------------------------------------------------+
// | 戻値 nomal:xmlfieldslist (optionlist html)
// +---------------------------------------------------------------------------+
function fncgetxmlfieldslist(
    $pi_name
    ,$selected
)
{
    global $_CONF;
    global $_TABLES;

    $lang_box_admin="LANG_".strtoupper($pi_name)."_ADMIN";
    global $$lang_box_admin;
    $lang_box_admin=$$lang_box_admin;

    global $LANG_confignames;
    global $LANG_MAPS_1;


    $retval = '';

    //
    $field_ary=array();

    //maps plugin
    $field_ary=fncGetFieldAry($pi_name);

    //
    $retval .= "<select name=field >".LB;
    $c=count($field_ary);
    if ($c>0){
        foreach( $field_ary as $fid => $fvalue ){
            $retval .= "<option value='{$fid}'";
            if ($fid == $selected) {
                $retval .= ' selected="selected"';
            }
            $retval .=        ">{$fvalue}";
            $retval .=    "</option>".LB;
        }
    }

    $retval .= '</select>';

    return $retval;
}
// +---------------------------------------------------------------------------+
// | 機能 get FieldAry
// | 書式 fncGetFieldAry($pi_name)
// +---------------------------------------------------------------------------+
// | 引数 $pi_name:
// +---------------------------------------------------------------------------+
// | 戻値 nomal:xmlfieldslist (optionlist html)
// +---------------------------------------------------------------------------+
function fncGetFieldAry(
    $pi_name
)
{

    $lang_box_admin="LANG_".strtoupper($pi_name)."_ADMIN";
    global $$lang_box_admin;
    $lang_box_admin=$$lang_box_admin;

    global $LANG_confignames;
    global $_PLUGINS;


    $field_ary=array();

    //maps
    if (in_array("maps", $_PLUGINS)){
        global $LANG_MAPS_1;

        $plg="maps";

        $field_ary['maps:name']=$plg.":".$LANG_MAPS_1['marker_name_label'].$lang_box_admin['must'];
        $field_ary['maps:address']=$plg.":".$LANG_MAPS_1['address_label'].$lang_box_admin['must'];

        $field_ary['maps:mname']=$plg.":".$LANG_MAPS_1['name_label'];
        $field_ary['maps:lat']=$plg.":".$LANG_MAPS_1['lat'];
        $field_ary['maps:lng']=$plg.":".$LANG_MAPS_1['lng'];

        $field_ary['maps:description']=$plg.":".$LANG_MAPS_1['description'];//詳細
        $field_ary['maps:payed']=$plg.":".$LANG_MAPS_1['payed'];//ペイドマーカー

        $field_ary['maps:remark']=$plg.":".$LANG_MAPS_1['remark'];//注意

        $field_ary['maps:street']=$plg.":".$LANG_MAPS_1['street_label'];//番地

        $field_ary['maps:city']=$plg.":".$LANG_MAPS_1['city_label'];//市

        $field_ary['maps:code']=$plg.":".$LANG_MAPS_1['code_label'];//〒

        $field_ary['maps:state']=$plg.":".$LANG_MAPS_1['state_label'];//都道府県
        $field_ary['maps:country']=$plg.":".$LANG_MAPS_1['country_label'];//国

        $field_ary['maps:tel']=$plg.":".$LANG_MAPS_1['tel_label'];//TEL

        $field_ary['maps:fax']=$plg.":".$LANG_MAPS_1['fax_label'];//FAX

        $field_ary['maps:web']=$plg.":".$LANG_MAPS_1['web_label'];//WEB

        $field_ary['maps:item_1']=$plg.":".$LANG_confignames['maps']['item_1'];//リソース #1
        $field_ary['maps:item_2']=$plg.":".$LANG_confignames['maps']['item_2'];//リソース #1
        $field_ary['maps:item_3']=$plg.":".$LANG_confignames['maps']['item_3'];//リソース #1
        $field_ary['maps:item_4']=$plg.":".$LANG_confignames['maps']['item_4'];//リソース #1
        $field_ary['maps:item_5']=$plg.":".$LANG_confignames['maps']['item_5'];//リソース #1
        $field_ary['maps:item_6']=$plg.":".$LANG_confignames['maps']['item_6'];//リソース #1
        $field_ary['maps:item_7']=$plg.":".$LANG_confignames['maps']['item_7'];//リソース #1
        $field_ary['maps:item_8']=$plg.":".$LANG_confignames['maps']['item_8'];//リソース #1
        $field_ary['maps:item_9']=$plg.":".$LANG_confignames['maps']['item_9'];//リソース #1
        $field_ary['maps:item_10']=$plg.":".$LANG_confignames['maps']['item_10'];//リソース #1
    }


    return  $field_ary;

}
// +---------------------------------------------------------------------------+
// | 機能  保存
// | 書式 fnc   Save ($pi_name,,$navbarMenu,$menuno)
// +---------------------------------------------------------------------------+
// | 引数 $pi_name:plugin name 'databox' 'userbox' 'formbox'
// | 引数 $navbarMenu
// | 引数 $menuno
// +---------------------------------------------------------------------------+
// | 戻値 nomal:戻り画面＆メッセージ
// +---------------------------------------------------------------------------+
function fncSave (
    $pi_name
    ,$navbarMenu
    ,$menuno

)
{
    global $_CONF;
    global $_TABLES;
    global $_USER;

    $box_conf="_".strtoupper($pi_name)."_CONF";
    global $$box_conf;
    $box_conf=$$box_conf;

    $lang_box_admin="LANG_".strtoupper($pi_name)."_ADMIN";
    global $$lang_box_admin;
    $lang_box_admin=$$lang_box_admin;

    $lang_box_admin_menu="LANG_".strtoupper($pi_name)."_admin_menu";
    global $$lang_box_admin_menu;
    $lang_box_admin_menu=$$lang_box_admin_menu;

    $table=$_TABLES[strtoupper($pi_name).'_def_xml'];

    $retval = '';

    // clean 'em up
    $seq = COM_applyFilter($_POST['seq'],true);

    $tag=COM_applyFilter($_POST['tag']);
    $tag = addslashes (COM_checkHTML (COM_checkWords ($tag)));
	$tag=mb_convert_kana($tag,"a");

    $value=COM_applyFilter($_POST['value']);
    $value = addslashes (COM_checkHTML (COM_checkWords ($value)));

    $field=COM_applyFilter($_POST['field']);
    $field= addslashes (COM_checkHTML (COM_checkWords ($field)));

    //-----
    $type=1;
    $uuid=$_USER['uid'];

    // CHECK　はじめ
    $err="";
    //ID コード
    if ($seq==0 ){
        //$err.=$lang_box_admin['err_uid']."<br/>".LB;
    }else{
        if (!is_numeric($seq) ){
            $err.=$lang_box_admin['err_id']."<br/>".LB;
        }
    }
    //tag必須
    if (empty($tag)){
        $err.=$lang_box_admin['err_tag']."<br/>".LB;
    }
    //field必須
    if (empty($field)){
        $err.=$lang_box_admin['err_field']."<br/>".LB;
    }
    //tag と field
    if ($tag==="" OR $field===""){
    }else{
         $cntsql="SELECT tag FROM {$table} ";
         $cntsql.=" WHERE ";
         $cntsql.=" tag='{$tag}' ";
         $cntsql.=" AND field='{$field}' ";

         $cntsql.=" AND seq<>{$seq}";
         $result = DB_query ($cntsql);
         $numrows = DB_numRows ($result);
         if ($numrows<>0 ) {
             $err.=$lang_box_admin['err_tag_w']."<br/>".LB;
         }
    }
    //field
    if ($field<>""){
         $cntsql="SELECT field FROM {$table} ";
         $cntsql.=" WHERE ";
         $cntsql.=" field='{$field}' ";
         $cntsql.=" AND seq<>{$seq}";
         $result = DB_query ($cntsql);
         $numrows = DB_numRows ($result);
         if ($numrows<>0 ) {
             $err.=$lang_box_admin['err_field_w']."<br/>".LB;
         }
    }


    //errorのあるとき
    if ($err<>"") {
        $page_title=$lang_box_admin['piname'].$lang_box_admin['edit'];

        $retval .= COM_siteHeader ('menu', $page_title);

        $retval .=ppNavbarjp($navbarMenu,$lang_box_admin_menu[$menuno]);
        $retval .= fncEdit($pi_name,$id,3,$err);
        $display .= COM_siteFooter ();

        return $retval;

    }
    // CHECK　おわり

    if ($seq==0){
        $w=DB_getItem($table,"max(seq)","1=1");
        if ($w=="") {
            $w=0;
        }
        $seq=$w+1;
    }

    $fields="seq";
    $values="$seq";

    $fields.=",tag";
    $values.=",'$tag'";

    $fields.=",value";
    $values.=",'$value'";

    $fields.=",field";
    $values.=",'$field'";

    $fields.=",uuid";
    $values.=",$uuid";

    $fields.=",udatetime";
    $values.=",NOW( )";
    //


    DB_save($table,$fields,$values,$return_page);

    if ($box_conf['aftersave_admin']==='no') {
        $page_title=$lang_box_admin['piname'].$lang_box_admin['edit'];

        $retval .= COM_siteHeader ('menu', $page_title);

        $retval .=ppNavbarjp($navbarMenu,$lang_box_admin_menu[$menuno]);
        $retval .= fncEdit($pi_name,$seq,1);

        $display .= COM_siteFooter ();

        return $retval;
    }else if ($box_conf['aftersave_admin']==='list'){
            $url = $_CONF['site_admin_url'] . "/plugins/$pi_name/pro.php";
            $item_url=COM_buildURL($url);
            $target='item';
    }else{
            $url = $_CONF['site_admin_url'] . "/plugins/$pi_name/pro.php";
            $item_url=COM_buildURL($url);
            $target=$box_conf['aftersave_admin'];
    }

    $return_page = PLG_afterSaveSwitch(
                    $target
                    ,$item_url
                    ,$pi_name
                    , 1);

    echo $return_page;


    //exit;

}
// +---------------------------------------------------------------------------+
// | 機能  削除
// | 書式 fncdelete ($pi_name)
// +---------------------------------------------------------------------------+
// | 戻値 nomal:戻り画面＆メッセージ
// +---------------------------------------------------------------------------+
function fncdelete (
    $pi_name
)
{
    global $_CONF;
    global $_TABLES;

    $lang_box_admin="LANG_".strtoupper($pi_name)."_ADMIN";
    global $$lang_box_admin;
    $lang_box_admin=$$lang_box_admin;

    $table=$_TABLES[strtoupper($pi_name).'_def_xml'];

    $seq = COM_applyFilter($_POST['seq'],true);

    // CHECK
    $err="";
    if ($err<>"") {
        $page_title=  $lang_box_admin['err'];
        $retval .= databox_siteHeader($pi_name,'_admin',$page_title);
        $retval .= COM_startBlock ($lang_box_admin['err'], '',
                            COM_getBlockTemplate ('_msg_block', 'header'));
        $retval .= $err;
        $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
        $retval .= databox_siteFooter($pi_name,'_admin');
        return $retval;
    }

    //
    DB_delete ($table, 'seq', $seq);

    return COM_refresh ($_CONF['site_admin_url']
                        . '/plugins/'.THIS_SCRIPT.'?msg=2');
}
// +---------------------------------------------------------------------------+
// | 機能  エキスポート実行
// | 書式 fncexportexec ($pi_name)
// +---------------------------------------------------------------------------+
// | 戻値 nomal: 結果画面
// +---------------------------------------------------------------------------+

function fncexportexec(
    $pi_name
)
{
    global $_CONF;

    global $logfile;
    global $logmode;


    $box_conf="_".strtoupper($pi_name)."_CONF";
    global $$box_conf;
    $box_conf=$$box_conf;

    $lang_box_admin="LANG_".strtoupper($pi_name)."_ADMIN";
    global $$lang_box_admin;
    $lang_box_admin=$$lang_box_admin;

    $importurl = COM_applyFilter($_POST['importurl']);

    if ($importurl===""){
        $importurl=$box_conf['path_xml_out'];
    }

    if  (file_exists($importurl) ){
        if ( is_dir($importurl) AND is_writable($importurl)){
            $fchk=true;
        }
    }else{
        $fchk=false;
    }


    $defxml=fncGetDefXml($pi_name);
    $cnt=count($defxml);
    if ($cnt>0){
        if  ($fchk){
            $rt=fncOutMaps($pi_name,$importurl,$defxml);
            $dummy = LIB_OutLog( $rt ,$logfile,$logmode);
        }else{
            $rt=$importurl." ". $lang_box_admin['err_not_exist'];
            $dummy = LIB_OutLog( $rt ,$logfile,$logmode);
        }
    }else{
        $rt="xml def data not exist";
    }


    return $rt;

}


// +---------------------------------------------------------------------------+
// | 機能  インポート画面表示
// | 書式 fncimport ($pi_name)
// +---------------------------------------------------------------------------+
// | 戻値 nomal:
// +---------------------------------------------------------------------------+
function fncimportexport (
    $pi_name
    ,$mode
    )
{
    global $_CONF;

    $box_conf="_".strtoupper($pi_name)."_CONF";
    global $$box_conf;
    $box_conf=$$box_conf;

    $lang_box_admin="LANG_".strtoupper($pi_name)."_ADMIN";
    global $$lang_box_admin;
    $lang_box_admin=$$lang_box_admin;

    $tmpl = new Template ($_CONF['path'] . "plugins/".THIS_PLUGIN."/templates/admin/");
    $tmpl->set_file(array('import' => 'import_url.thtml'));

    $tmpl->set_var('site_admin_url', $_CONF['site_admin_url']);

    $tmpl->set_var('gltoken_name', CSRF_TOKEN);
    $tmpl->set_var('gltoken', SEC_createToken());
    $tmpl->set_var ( 'xhtml', XHTML );

    $tmpl->set_var('script', THIS_SCRIPT);

    if ($mode==="importform"){
        $tmpl->set_var('mode', 'import');
        $tmpl->set_var('defaultpath', $box_conf['path_xml']);
        $tmpl->set_var('help', $lang_box_admin['importmsg']);
    }else{
        $tmpl->set_var('mode', 'export');
        $tmpl->set_var('defaultpath', $box_conf['path_xml_out']);
        $tmpl->set_var('help', $lang_box_admin['exportmsg']);
    }

    $tmpl->set_var('default', $lang_box_admin['default']);
    $tmpl->set_var('submit', $lang_box_admin['submit']);

    $tmpl->parse ('output', 'import');
    $import = $tmpl->finish ($tmpl->get_var ('output'));

    $retval="";
    $retval .= COM_startBlock ($lang_box_admin[$mode], '',
                            COM_getBlockTemplate ('_admin_block', 'header'));
    $retval .= $import;
    $retval .= COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer'));

    return $retval;
}


// +---------------------------------------------------------------------------+
// | 機能  インポート実行
// | 書式 fncimportexec ($pi_name)
// +---------------------------------------------------------------------------+
// | 戻値 nomal: 結果画面
// +---------------------------------------------------------------------------+

function fncimportexec(
    $pi_name
)
{
    global $_CONF;
    global $_ASSIST_CONF;
	global $LANG_ASSIST_ADMIN;

    global $logfile;
    global $logmode;
	
    $pi_name="assist";

    $importurl = COM_applyFilter($_POST['importurl']);

    if ($importurl===""){
        $importurl=$_ASSIST_CONF['path_xml'];
    }


    if (@fopen($importurl,'r')){
        $fchk=true;
        //fclose($importurl);
    }else{
        if  (file_exists($importurl)){
            $fchk=true;
        }else{
            $fchk=false;
        }
	}
	
	$cnt_ok=0;
	$cnt_ng=0;

    $defxml=assist_GetDefXml($pi_name);
    $cnt=count($defxml);
    if ($cnt>0){

        if  ($fchk){
            if (is_dir($importurl)){
                $fd=$importurl;
                $files=LIB_getfilelist($fd,"xml");
                for ($i = 1; $i <= count($files); $i++) {
                    $fl=$fd."/".current($files);

                    $logentry=$fl;
                    $dummy = LIB_OutLog( $logentry ,$logfile,$logmode);
					$rt1=assist_xmlimport($pi_name,$fl,$defxml);

					$cnt_ok=$cnt_ok+$rt1['ok'];
					$cnt_ng=$cnt_ng+$rt1['ng'];
					$wmsg=current($files)." ".$rt1['msg'];
                    $dummy = LIB_OutLog( $wmsg ,$logfile,$logmode);
                    $rt.=$wmsg."<br>";
                    next($files);
                }
            }else{
				$rt1=assist_xmlimport($pi_name,$importurl,$defxml);
				$cnt_ok=$cnt_ok+$rt1['ok'];
				$cnt_ng=$cnt_ng+$rt1['ng'];
                $rt=$rt1['msg']."<br>";
                $dummy = LIB_OutLog( $rt['msg'] ,$logfile,$logmode);
            }
        }else{
            $rt=$importurl." ". $LANG_ASSIST_ADMIN['err_not_exist'];
            $dummy = LIB_OutLog( $rt ,$logfile,$logmode);
        }
    }else{
        $rt="xml def data not exist";
    }
	
	$rt.=$LANG_ASSIST_ADMIN['jobend'];
	$rt.=	sprintf ($LANG_ASSIST_ADMIN['cnt_ok'] , $cnt_ok);
	$rt.=	sprintf ($LANG_ASSIST_ADMIN['cnt_ng'] , $cnt_ng);
	
    return $rt;

}




//MapsMerkar Out
function fncOutMaps(
    $pi_name
    ,$outfrd
    ,$defxml
    )
{
    global $_TABLES;

    //-----
    $tbl1=$_TABLES['maps_markers'];
    //-----
    $sql = "SELECT ".LB;
    $sql .= " * ".LB;
    $sql .= " FROM ".LB;
    $sql .= " {$tbl1} AS t1 ".LB;

    $result = DB_query ($sql);
    $cnt = DB_numRows ($result);

    $result = DB_query ($sql);
    $numrows = DB_numRows ($result);
    if ($numrows > 0) {
        for ($i = 0; $i < $numrows; $i++) {
            $A = DB_fetchArray ($result);

            $mkid=COM_applyFilter($A['mkid']);

            $wtime=time();
            $filename = $outfrd."/".$wtime.'_markers_'.$mkid.'.xml';  //  ファイル名

            $dom = new DomDocument('1.0');  // DOMを作成
            $dom->encoding = "UTF-8"; // 文字コードをUTF-8に
            $dom->formatOutput = true; // 出力XMLを整形(改行,タブ)する

            //@@@@ $ExportData = $dom->appendChild($dom->createElement('ExportData'));
            //@@@@ $Head = $ExportData->appendChild($dom->createElement('Head'));
            //@@@@ $Body = $ExportData->appendChild($dom->createElement('Body'));
            //@@@@ // ヘッダID を <Head>に
            //@@@@ $HID= $Head->appendChild($dom->createElement('HeadID'));
            //@@@@ $HID->appendChild($dom->createTextNode('ヘッダID'));
            //@@@@ // ヘッダタイトル を <Head>に
            //@@@@ $HTtl= $Head->appendChild($dom->createElement('HeadTitle'));
            //@@@@ $HTtl->appendChild($dom->createTextNode('ヘッダタイトル'));
            //@@@@ // 内容１ を <Body>に
            //@@@@ $BContent= $Body->appendChild($dom->createElement('Content'));
            //@@@@ $BContent->appendChild($dom->createTextNode('内容１'));

            //ADD ROOT
            $ROOTData = $dom->appendChild($dom->createElement('ROOT'));

            //ADD ROOT_TAG
            $cnt=count($defxml);
            for ($j = 0; $j < $cnt; $j++) {

                $tag=    $defxml[$j]['tag'];
                $value=  $defxml[$j]['value'];
                $type =  $defxml[$j]['type'];
                $field=  $defxml[$j]['field'];

                //maps項目
                if ($type==="maps"){
                    $value=COM_applyFilter($A[$field]);
                    $FIELDData= $ROOTData->appendChild($dom->createElement($tag));
                    $FIELDData->appendChild($dom->createTextNode($value));
                }
            }

            $dom->formatOutput = true; // set the formatOutput attribute of
                                       // domDocument to true
            // DomXMLをXML形式で出力
            $rt=$dom->saveXML();
            $dom->save($filename); // save as file
            //$dom->saveXML($filename);

        }
    }

    $rt="Maps Merkar ".$numrows." out(".$wtime.")";
    return $rt;

}


//MapsMerkar Output
function fncOutputMaps(
    $maps
    )
{
    global $_CONF;
    global $_TABLES;

    global $_MAPS_CONF;
    global $_USER;
    global $_GROUPS;

    global $LANG_ASSIST_ADMIN;


    $group_id=$_GROUPS['Maps Admin'];

    $array = array();
    SEC_setDefaultPermissions($array, $_MAPS_CONF['default_permissions']);
    $perm_owner = $array['perm_owner'];
    $perm_group = $array['perm_group'];
    $perm_anon = $array['perm_anon'];
    $perm_members = $array['perm_members'];


    $pi_name="assist";
    $err="";

    //-----
    $name= $maps['name'];
    if ($name==""){
        $err.=$LANG_ASSIST_ADMIN['err_marker_name'];
    }
    $address = $maps['address'];
    if ($address==""){
        $err.=$LANG_ASSIST_ADMIN['err_marker_address'];
    }
	$lat=$maps['lat'];
	$lng=$maps['lng'];

	// prepare strings for insertion
	$created = date("YmdHis");
	$modified = date("YmdHis");

    // lat, lng can only contain numbers and a decimal
	if (empty($lat) || empty($lng)) {
	    $coords = MAPS_getCoords($address, $lat, $lng);
		if ($lat == 0 && $lng == 0) {
            $err.=$LANG_ASSIST_ADMIN['err_marker_coords'];
		}
	}

    //errorのあるとき
    if ($err<>"") {
        return $err;

    }

    $newmkid = addslashes (COM_makeSid ());

    $mid=DB_getItem($_TABLES['maps_maps'], 'mid');
	if ($mid=="") {
        $err=$LANG_ASSIST_ADMIN['err_map'];
        return $err;
	}

    if ($maps['mname']<>""){//マップ名
        $mid=DB_getItem($_TABLES['maps_maps'], 'mid',"name='{$maps['mname']}'");
    	if ($mid=="") {
            $err=$LANG_ASSIST_ADMIN['err_map'];
            return $err;
    	}
    }


    $validity=$_MAPS_CONF['map_hidden'];//有効期限
    $active=$_MAPS_CONF['map_active'];
    $payed=$_MAPS_CONF['payed'];//ペイドマーカー

    $description=$maps['description'];//詳細
    $remark=$maps['remark'];//注意
    $street=$maps['street'];//番地
    $city=$maps['city'];//市
    $code=$maps['code'];//〒
    $state=$maps['state'];//都道府県
    $country=$maps['country'];//国
    $tel=$maps['tel'];//TEL
    $fax=$maps['fax'];//FAX
    $web=$maps['web'];//WEB
    $item_1=$maps['item_1'];//リソース #1
    $item_2=$maps['item_2'];//リソース #2
    $item_3=$maps['item_3'];//リソース #3
    $item_4=$maps['item_4'];//リソース #4
    $item_5=$maps['item_5'];//リソース #5
    $item_6=$maps['item_6'];//リソース #6
    $item_7=$maps['item_7'];//リソース #7
    $item_8=$maps['item_8'];//リソース #8
    $item_9=$maps['item_9'];//リソース #9
    $item_10=$maps['item_10'];//リソース #10

    $owner_id=$_USER['uid'];
    $group_id=$_GROUPS['Maps Admin'];

    $array = array();
    SEC_setDefaultPermissions($array, $_MAPS_CONF['default_permissions']);
    $perm_owner = $array['perm_owner'];
    $perm_group = $array['perm_group'];
    $perm_anon = $array['perm_anon'];
    $perm_members = $array['perm_members'];


    //-------
    $fields="mkid".LB;
    $values="'$newmkid'".LB;

    $fields.=",name".LB;
    $values.=",'$name'".LB;

    $fields.=",description".LB;
    $values.=",'$description'".LB;

    $fields.=",created".LB;
    $values.=",'$created'".LB;

    $fields.=",modified".LB;
    $values.=",'$modified'".LB;

    $fields.=",payed".LB;
    $values.=",'$payed'".LB;

    $fields.=",validity".LB;
    $values.=",'$validity'".LB;

    $fields.=",active".LB;
    $values.=",'$active'".LB;


    $fields.=",address".LB;
    $values.=",'$address'".LB;

    $fields.=",lat".LB;
    $values.=",'$lat'".LB;

    $fields.=",lng".LB;
    $values.=",'$lng'".LB;

    $fields.=",mid".LB;
    $values.=",'$mid'".LB;

    $fields.=",remark".LB;
    $values.=",'$remark'".LB;

    $fields.=",street".LB;
    $values.=",'$street'".LB;

    $fields.=",city".LB;
    $values.=",'$city'".LB;

    $fields.=",code".LB;
    $values.=",'$code'".LB;

    $fields.=",state".LB;
    $values.=",'$state'".LB;

    $fields.=",country".LB;
    $values.=",'$country'".LB;

    $fields.=",tel".LB;
    $values.=",'$tel'".LB;

    $fields.=",fax".LB;
    $values.=",'$fax'".LB;

    $fields.=",web".LB;
    $values.=",'$web'";

    $fields.=",item_1".LB;
    $values.=",'$item_1'".LB;
    $fields.=",item_2".LB;
    $values.=",'$item_2'".LB;
    $fields.=",item_3".LB;
    $values.=",'$item_3'".LB;
    $fields.=",item_4".LB;
    $values.=",'$item_4'".LB;
    $fields.=",item_5".LB;
    $values.=",'$item_5'".LB;
    $fields.=",item_6".LB;
    $values.=",'$item_6'".LB;
    $fields.=",item_7".LB;
    $values.=",'$item_7'".LB;
    $fields.=",item_8".LB;
    $values.=",'$item_8'".LB;
    $fields.=",item_9".LB;
    $values.=",'$item_9'".LB;
    $fields.=",item_10".LB;
    $values.=",'$item_10'".LB;

    $fields.=",owner_id".LB;
    $values.=",'$owner_id'".LB;

    $fields.=",group_id".LB;
    $values.=",'$group_id'".LB;

    $fields.=",perm_owner".LB;
    $values.=",'$perm_owner'".LB;

    $fields.=",perm_group".LB;
    $values.=",'$perm_group'".LB;

    $fields.=",perm_members".LB;
    $values.=",$perm_members".LB;

    $fields.=",perm_anon".LB;
    $values.=",$perm_anon".LB;

    $fields.=",submission".LB;
    $values.=",0".LB;

    updateMap($mid);

    //    if (DB_error()) {
    //        $err="dberror"；
    //    }

    DB_save($_TABLES['maps_markers'],$fields,$values);


    //$dummy=fncsendmail ('data',$id);

    $return="INSERT ".$newmkid." ".$name;

    return $return;
}

// +---------------------------------------------------------------------------+
// | 機能 maps markers truncate
// | 書式 fncmarkersclear()
// +---------------------------------------------------------------------------+
// | 戻値 nomal:
// +---------------------------------------------------------------------------+

function fncmarker()
{

    global $_TABLES;
    global $_CONF;
	
    $maps = $_POST['maps'];
	
    $_SQL =array();
	
    if (is_array($maps)){
		for ($i = 1; $i <= count($maps); $i++) {
			
			$mid=current($maps);
			
			$_SQL[] = "DELETE FROM {$_TABLES['maps_markers']} WHERE mid=".$mid;
			next($maps);
		}
	}
    for ($i = 1; $i <= count($_SQL); $i++) {
		$w=current($_SQL);
        DB_query($w);
        next($_SQL);
    }
    if (DB_error()) {
        COM_errorLog("error Assist Proversion maps markers clear ",1);
        return "initialize error";
    }

    COM_errorLog("Success - Assist Proversion maps markers clear",1);
    return "Maps Markers clear finish!";
}

// +---------------------------------------------------------------------------+
// | 機能 初期化
// | 書式 fncinit()
// +---------------------------------------------------------------------------+
// | 戻値 nomal:
// +---------------------------------------------------------------------------+

function fncinit()
{

    global $_TABLES;
    global $_CONF;

    $_SQL =array();

    require_once($_CONF['path'] . 'plugins/assist/proversion/sql/mysql_install_xml.php');

    //------------------------------------------------------------------
    for ($i = 1; $i <= count($_SQL); $i++) {
		$w=current($_SQL);
        DB_query(current($_SQL));
        next($_SQL);
    }
    if (DB_error()) {
        COM_errorLog("error Assist Proversion Initialize ",1);
        return "initialize error";
    }

    COM_errorLog("Success - Assist Proversion Initialize",1);
    return "initialize finish!";
}


function fncConfirmation(
    $pi_name
    ,$mode
)
{
    global $_CONF;
    global $LANG_ADMIN;


    $lang_box_admin="LANG_".strtoupper($pi_name)."_ADMIN";
    global $$lang_box_admin;
    $lang_box_admin=$$lang_box_admin;

    $tmpl = new Template ($_CONF['path'] . "plugins/".THIS_PLUGIN."/templates/admin/");
    $tmpl->set_file(array('confirm' => 'confirmation.thtml'));


    $tmpl->set_var('site_admin_url', $_CONF['site_admin_url']);
    $tmpl->set_var('gltoken_name', CSRF_TOKEN);
    $tmpl->set_var('gltoken', SEC_createToken());
    $tmpl->set_var ( 'xhtml', XHTML );

    //
    $actionname=$lang_box_admin[$mode];
    $actionprg="{$_CONF['site_admin_url']}/plugins/".THIS_SCRIPT."?mode={$mode}exec";

    $tmpl->set_var('actionname', $actionname);
    $tmpl->set_var('actionprg', $actionprg);
	
	if ($mode==="markerclear"){
		$tmpl->set_var('lang_checklist', "map:");
		$checklist=fncgetcheckList ("map");
		$tmpl->set_var('checklist', $checklist);
	}

    // SAVE、CANCEL ボタン
    $tmpl->set_var('lang_submit', $LANG_ADMIN['submit']);
    $tmpl->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $tmpl->set_var('mode', $mode."exec");

    $tmpl->parse ('output', 'confirm');
    $comfirm = $tmpl->finish ($tmpl->get_var ('output'));

    $retval = $comfirm;


    return $retval;
}

// +---------------------------------------------------------------------------+
// | 機能  チェックリスト作成
// | 書式 fbcgetcheckList($kind,$selected = "")
// +---------------------------------------------------------------------------+
// | 引数 $kind:種類
// | 引数 $selected:選択値　省略時
// +---------------------------------------------------------------------------+
// | 戻値 nomal:チェックリスト
// +---------------------------------------------------------------------------+
//20101116
function fncgetcheckList(
    $kind
    ,$selected = ""
)
{
global $_TABLES;


    $retval = '';

    if ($kind="maps"){
        $sql = "SELECT ";
        $sql .= " mid".LB;
        $sql .= ",name".LB;
		$sql .= " FROM {$_TABLES['maps_maps']}".LB;
        $sql .= " ORDER BY mid".LB;
    }
    $result = DB_query( $sql );
    $nrows = DB_numRows( $result );

    if (is_array($selected)){
            $S = $selected;
    }else{
        if( !empty( $selected ))    {
            $S = explode( ' ', $selected );
        }else {
            $S = array();
        }
	}
	
    $old_group_id="";
    for( $i = 0; $i < $nrows; $i++ )    {
        $A = DB_fetchArray( $result, true );
        $retval .="<nobr>";
        $retval .= '<input type="checkbox" name="' . $kind . '[]" value="' . $A[0] ;
        $retval .= '"';
        $retval .= ' class="clcr" ';
        for( $x = 0; $x < sizeof( $S ); $x++ )            {
            if( $A[0] == $S[$x] )                {
                $retval .= ' checked="checked"';
            }
        }
        $retval .= '>' . stripslashes( $A[1] ) . '</nobr>' . LB;
    }

    return $retval;
}


// +---------------------------------------------------------------------------+
// | MAIN                                                                      |
// +---------------------------------------------------------------------------+
//############################
$pi_name    = 'assist';
//############################

// 引数
$action = '';
if (isset ($_REQUEST['action'])) {
    $action = COM_applyFilter ($_REQUEST['action'], false);
}
if (isset ($_REQUEST['mode'])) {
    $mode = COM_applyFilter ($_REQUEST['mode'], false);
}
$msg = '';
if (isset ($_REQUEST['msg'])) {
    $msg = COM_applyFilter ($_REQUEST['msg'], true);
}
$seq = '';
if (isset ($_REQUEST['seq'])) {
    $seq = COM_applyFilter ($_REQUEST['seq'], true);
}

$old_mode="";
if (isset($_REQUEST['old_mode'])) {
    $old_mode = COM_applyFilter($_REQUEST['old_mode'],false);
    if ($mode==$LANG_ADMIN['cancel']) {
        $mode = $old_mode;
    }
}

if (($mode == $LANG_ADMIN['save']) && !empty ($LANG_ADMIN['save'])) { // save
    $mode="save";
}else if (($mode == $LANG_ADMIN['delete']) && !empty ($LANG_ADMIN['delete'])) {
    $mode="delete";
}

if ($action == $LANG_ADMIN['cancel'])  { // cancel
    $mode="";
}

//---
$sql="SELECT seq FROM ".$_TABLES['ASSIST_def_xml'];
$sql="show tables from {$_DB_name} like '{$_TABLES['ASSIST_def_xml']}'" ;
$sql="show tables like '{$_TABLES['ASSIST_def_xml']}'" ;

$rt=@mysql_query($sql);
$rt=mysql_num_rows($rt);

if  ($rt===0){
	if ($mode<>"initexec"){
		$mode="init";
	}
}

if ($mode=="" OR $mode=="edit" OR $mode=="new" OR $mode=="drafton" OR $mode=="draftoff"
    OR $mode=="init" OR $mode=="list" OR $mode=="markerclear"
    OR $mode=="exportform" OR $mode=="importform" OR $mode=="copy") {
}else{
    if (!SEC_checkToken()){
 //    if (SEC_checkToken()){//テスト用
        COM_accessLog("User {$_USER['username']} tried to illegally and failed CSRF checks.");
        echo COM_refresh($_CONF['site_admin_url'] . '/index.php');
        exit;
    }
}



//
$menuno=8;
$display = '';

switch ($mode) {
    case 'export':// エキスポート実行
        $page_title=$LANG_ASSIST_ADMIN['piname'].$LANG_ASSIST_ADMIN['import'];
        $display .= COM_siteHeader ('menu', $page_title);
        $display.=ppNavbarjp($navbarMenu,$LANG_ASSIST_admin_menu[$menuno]);
        $display .= fncMenu($pi_name);

        $display .= fncexportexec($pi_name);

        break;

    case 'import':// インポート実行
        $page_title=$LANG_ASSIST_ADMIN['piname'].$LANG_ASSIST_ADMIN['import'];
        $display .= COM_siteHeader ('menu', $page_title);
        $display.=ppNavbarjp($navbarMenu,$LANG_ASSIST_admin_menu[$menuno]);
        $display .= fncMenu($pi_name);

        $display .= fncimportexec($pi_name);
        break;

    case 'new':// 新規登録
        $page_title=$LANG_ASSIST_ADMIN['piname'].$LANG_ASSIST_ADMIN['new'];
        $display .= COM_siteHeader ('menu', $page_title);
        $display .=ppNavbarjp($navbarMenu,$LANG_ASSIST_admin_menu[$menuno]);
        $display .= fncMenu($pi_name);
        $display .= fncEdit($pi_name,"",$msg);
        $display .= COM_siteFooter ();

        break;

    case 'save':// 保存
        $display .= fncSave ($pi_name,$navbarMenu,$menuno);
        break;
    case 'delete':// 削除
        $display .= fncdelete($pi_name);
        break;
    case 'edit':// 編集
        if (!empty ($seq) ) {
            $page_title=$LANG_ASSIST_ADMIN['piname'].$LANG_ASSIST_ADMIN['edit'];
            $display .= COM_siteHeader ('menu', $page_title);

            $display.=ppNavbarjp($navbarMenu,$LANG_ASSIST_admin_menu[$menuno]);
            $display .= fncMenu($pi_name);
            $display .= fncEdit($pi_name,$seq,$msg);
            $display .= COM_siteFooter ();
        }
        break;

    case 'exportform':// エクスポート　画面
    case 'importform':// インポート　画面
        $page_title=$LANG_ASSIST_ADMIN['piname'].$LANG_ASSIST_ADMIN[$mode];
        $display .= COM_siteHeader ('menu', $page_title);

        $display.=ppNavbarjp($navbarMenu,$LANG_ASSIST_admin_menu[$menuno]);
        $display .= fncMenu($pi_name);
        $display .= fncimportexport($pi_name,$mode);
        $display .= COM_siteFooter ();

        break;


    case 'init'://初期化 Confirmation
    case 'markerclear'://MAPSプラグイン Markers clear　Confirmation
        $page_title=$LANG_ASSIST_ADMIN['piname'];
        $display .= COM_siteHeader ('menu', $page_title);

        $display.=ppNavbarjp($navbarMenu,$LANG_ASSIST_admin_menu[$menuno]);

        $display .= fncMenu($pi_name);
        $display .= fncConfirmation($pi_name,$mode);
        $display .= COM_siteFooter ();

        break;
    case 'initexec'://初期化

        $page_title=$LANG_ASSIST_ADMIN['piname'];
        $display .= COM_siteHeader ('menu', $page_title);

        $display.=ppNavbarjp($navbarMenu,$LANG_ASSIST_admin_menu[$menuno]);
        $display .= fncMenu($pi_name);
        $display .= fncinit();
        $display .= COM_siteFooter ();
        break;
    case 'markerclearexec'://MAPSプラグイン Markers clear
        $page_title=$LANG_ASSIST_ADMIN['piname'];
        $display .= COM_siteHeader ('menu', $page_title);

        $display.=ppNavbarjp($navbarMenu,$LANG_ASSIST_admin_menu[$menuno]);
        $display .= fncMenu($pi_name);
        $display .= fncmarker();
        $display .= COM_siteFooter ();

        break;
    case 'list':// 一覧
	default:// 初期表示、
	
	
        $page_title=$LANG_ASSIST_ADMIN['piname'];
        $display .= COM_siteHeader ('menu', $page_title);

        if (isset ($msg)) {
            $display .= COM_showMessage ($msg,$pi_name);
        }
        $display.=ppNavbarjp($navbarMenu,$LANG_ASSIST_admin_menu[$menuno]);

		$display .= fncMenu($pi_name);
        $display .= fncList($pi_name);
		$display .= COM_siteFooter ();
        break;



}

COM_output($display);

?>
